<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Vue2检测数据改变 数组</title>
</head>
<body>
    <div id="app">
        <div style="color:red">
           <b>push pop shift unshift splice sort reverse 只有操作了这几个方法来操作数组，Vue才会检测到数据变化，才会重新解析DOM</b>
           <div>
               这几个方法是重新封装好的，封装完之后的方法做了两件事，1，调用原来的push方法；2，更新DOM
           </div>
           <h1>vm._data.student.hobbys.push === Array.prototype.push   false</h1>
           <h1>[].push === Arrya.prototype.push   true</h1>
        </div>
        <hr>
        <h1>爱好</h1>
        <ul>
            <li v-for="h in student.hobbys" :key="h">
                {{h}}
            </li>
        </ul>
        <h1>朋友</h1>
        <ul>
            <li v-for="p in student.friends" :key="p.name">
                <b>{{p.name}}--{{p.age}}</b>
            </li>
        </ul>
    </div>
    <script>
        const vm = new Vue({
            el:'#app',
            data:{
                student:{
                    name:'tom',
                    age:{
                        rage:40,
                        sage:29
                    },
                    hobbys:['抽烟','喝酒','烫头'],
                    friends:[
                        {name:'Amy',age:13},
                        {name:'Jake',age:23},
                    ]
                }
            },
            methods:{
                
            }
        })
        // push pop shift unshift splice sort reverse 
        // 
    </script>
</body>
</html>